--[[
用户数据模型
]]
local RoleModel =  {};




RoleModel.UseName = nil;
RoleModel.Password = nil;
RoleModel.InternetConnection = false;--单机模式




function RoleModel.new()
	--[[
		CCNetworkStatusNotReachable: 无法访问互联网
	   	kCCNetworkStatusReachableViaWiFi: 通过 WIFI
	   	kCCNetworkStatusReachableViaWWAN: 通过 3G 网络
	]]
	--状态
	local networkStatus = network.getInternetConnectionStatus()
	if networkStatus == kCCNetworkStatusReachableViaWiFi or 
	networkStatus == kCCNetworkStatusReachableViaWWAN then
	else --单机	
	end
	
	
	RoleModel.UseName = GameSession.get("UseName")
	RoleModel.Password =  GameSession.get("Password")
	
	return networkStatus;
end



function RoleModel.Login(data,callBack)
	local loginCallBack = function (result)
		local status = result['status'] --后台返回的数据成功与否的编码
		if status == 1 then 
			RoleModel.UseName = data.UseName
			RoleModel.Password = data.Password
			RoleModel.InternetConnection = true;
			
			GameSession.set("UseName",RoleModel.UseName);
			GameSession.set("Password",RoleModel.Password);
			GameSession.save()
			
			callBack(status);
		else
			
		end
	end
	HttpLoad:json(GameServerProperties.LoginAction,{UseName = data.UseName,Password = data.Password},loginCallBack)
end






return RoleModel
